package com.insist.framework;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2016/7/6.
 */
public class CmmAjaxFilter implements Filter {

    public void destroy() {
    }
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse, FilterChain filterchain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        response.addHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
        response.addHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
        response.addHeader("Access-Control-Allow-Headers", "POWERED-BY-FANTONG");
        response.addHeader("Access-Control-Allow-Credentials", "true");
        response.addHeader("Access-Control-Max-Age", "30");
        filterchain.doFilter(servletRequest, servletResponse);
    }
    public void init(FilterConfig config) throws ServletException {
    }
}
